﻿using Microsoft.Owin.Hosting;
using System.ServiceProcess;
using Inovout.Runtime;
using System.Collections.Generic;
using System;

namespace Inovout.Web.Http
{
    public partial class WebApiService : ServiceBase
    {
        public WebApiService()
        {
            InitializeComponent();
        }

        public void Start(string[] args)
        {
            OnStart(args);
        }
        private readonly string HostPortKey = "host.port";
        protected override void OnStart(string[] args)
        {
            IDictionary<string, string> properties = ApplicationProperties.GetProperties();
            StartOptions startOptions = new StartOptions();
            startOptions.Port = int.Parse(properties[HostPortKey]);
            Console.WriteLine("port:"+startOptions.Port.ToString());
            WebApp.Start<WebApiApplication>(startOptions);
        }

        protected override void OnStop()
        {
        }
    }
}
